1 Prerequisites

1.1 Clearing the environment

rm(list=ls())
ls()
## character(0)

1.2 Packages and libraries

#which directory at the moment
getwd()
## [1] "/Users/arifpras/OneDrive - The University of Nottingham/BB_KelasData/WranglingViz"
#setting working directory
setwd("/Users/arifpras/OneDrive - The University of Nottingham/BB_KelasData/KelasData")

#dir()

1.3 Datasets

#sources:
##--https://www.kaggle.com/michau96
##--https://www.kaggle.com/aditya2803
##--https://www.opfanpage.com/2018/06/29/one-piece-power-ranking-chart/
##--https://listfist.com/list-of-one-piece-characters-by-age

#".csv" files - local

#op_chapters <- read.csv(file.choose())
#op_chapters <- read.csv("/Users/arifpras/OneDrive - The University of Nottingham/BB_KelasData/KelasData/00_Datasets/OP_chapters.csv")

#op_characters <- read.csv(file.choose())
#op_characters <- read.csv("/Users/arifpras/OneDrive - The University of Nottingham/BB_KelasData/KelasData/00_Datasets/OP_characters.csv")

#op_ratings <- read.csv(file.choose())
#op_ratings <- read.csv("/Users/arifpras/OneDrive - The University of Nottingham/BB_KelasData/KelasData/00_Datasets/OP_ratings.csv")

#op_powers <- read.csv(file.choose())
#op_powers <- read.csv("/Users/arifpras/OneDrive - The University of Nottingham/BB_KelasData/KelasData/00_Datasets/OP_powers.csv")

#op_ages <- read.csv(file.choose())
#op_ages <- read.csv("/Users/arifpras/OneDrive - The University of Nottingham/BB_KelasData/KelasData/00_Datasets/OP_ages.csv")

#".xlsx" files - local
#op_chapters <- read_excel(path = "/Users/arifpras/OneDrive - The University of Nottingham/BB_KelasData/KelasData/00_Datasets/OP_all.xlsx", sheet = "OP_chapters")
#op_characters <- read_excel(path = "/Users/arifpras/OneDrive - The University of Nottingham/BB_KelasData/KelasData/00_Datasets/OP_all.xlsx", sheet = "OP_characters")
#op_ratings <- read_excel(path = "/Users/arifpras/OneDrive - The University of Nottingham/BB_KelasData/KelasData/00_Datasets/OP_all.xlsx", sheet = "OP_ratings")
op_powers <- readxl::read_excel(path = "/Users/arifpras/OneDrive - The University of Nottingham/BB_KelasData/KelasData/00_Datasets/OP_all.xlsx", sheet = 4)
op_ages <- read_excel(path = "/Users/arifpras/OneDrive - The University of Nottingham/BB_KelasData/KelasData/00_Datasets/OP_all.xlsx", sheet = "OP_ages")

#".csv" files - cloud
#op_chapters <- read.csv("https://www.dropbox.com/s/t1vrxsa4ad0m2c4/OP_chapters.csv?dl=1")
#op_characters <- read.csv("https://www.dropbox.com/s/e74njw4iw7qfzbl/OP_characters.csv?dl=1")
#op_ratings <- read.csv("https://www.dropbox.com/s/qvdhlnkyk02giuj/OP_ratings.csv?dl=1")
#op_powers <- read.csv("https://www.dropbox.com/s/t3gbzzscz438ecp/OP_powers.csv?dl=1")
#op_ages <- read.csv("https://www.dropbox.com/s/r24vzv7eyz35irr/OP_ages.csv?dl=1")

#require(devtools)
#install_github("Displayr/flipAPI")
#library(flipAPI)

#".xlsx" files - cloud
#op_chapters <- flipAPI::DownloadXLSX("https://www.dropbox.com/s/5mev3xo0cd3tc61/OP_all.xlsx?dl=0", sheet = 1)
#op_characters <- flipAPI::DownloadXLSX("https://www.dropbox.com/s/5mev3xo0cd3tc61/OP_all.xlsx?dl=0", sheet = "OP_characters")
#op_ratings <- flipAPI::DownloadXLSX("https://www.dropbox.com/s/5mev3xo0cd3tc61/OP_all.xlsx?dl=0", sheet = 3)
#op_powers <- flipAPI::DownloadXLSX("https://www.dropbox.com/s/5mev3xo0cd3tc61/OP_all.xlsx?dl=0", sheet = "OP_powers", want.data.frame = TRUE)
#op_ages <- flipAPI::DownloadXLSX("https://www.dropbox.com/s/5mev3xo0cd3tc61/OP_all.xlsx?dl=0", sheet = "OP_ages", want.data.frame = TRUE)
str(op_powers)
## tibble [56 × 4] (S3: tbl_df/tbl/data.frame)
##  $ power       : num [1:56] 100 100 100 100 99 95 95 94.5 94 93 ...
##  $ character   : chr [1:56] "Red Haired Shanks" "Marshall D. Teach" "Charlotte Linlin" "Kaido" ...
##  $ level       : chr [1:56] "Yonko" "Yonko" "Yonko" "Yonko" ...
##  $ affiliations: chr [1:56] "Red Haired Pirates" "Blackbeard Pirates" "Big Mom Pirates" "Beasts Pirates" ...
str(op_ages)
## tibble [482 × 2] (S3: tbl_df/tbl/data.frame)
##  $ name: chr [1:482] "Zunesha" "Jarul" "Jorul" "Hatcha" ...
##  $ age : num [1:482] 1000 408 344 188 160 160 160 159 156 153 ...
glimpse(op_powers)
## Rows: 56
## Columns: 4
## $ power        <dbl> 100.0, 100.0, 100.0, 100.0, 99.0, 95.0, 95.0, 94.5, 94.0,…
## $ character    <chr> "Red Haired Shanks", "Marshall D. Teach", "Charlotte Linl…
## $ level        <chr> "Yonko", "Yonko", "Yonko", "Yonko", "Admiral", "Admiral",…
## $ affiliations <chr> "Red Haired Pirates", "Blackbeard Pirates", "Big Mom Pira…
glimpse(op_ages)
## Rows: 482
## Columns: 2
## $ name <chr> "Zunesha", "Jarul", "Jorul", "Hatcha", "Brogy", "Dorry", "Morley"…
## $ age  <dbl> 1000, 408, 344, 188, 160, 160, 160, 159, 156, 153, 141, 120, 105,…

2 Data Wrangling

2.1 Filtering

op_powers %>% 
  dplyr::filter(affiliations == "Marine")

2.2 Arranging

op_powers %>%
  #arrange(character) #ascending, alphabetical order
  arrange(desc(character)) #descending, alphabetical order

2.3 Recoding

law <- op_powers %>% 
  mutate(character02 = 
           recode(character, 
                  "Trafalgar D. Water Law" = "Trafalgar D. Law"))

law %>% filter(affiliations == "Heart Pirates") %>% 
  select(character, character02)

2.4 Slicing

op_powers %>% 
  slice(18L) #variable number 18
op_powers %>% 
  slice(n()) #the last variable
op_powers %>% 
  slice(50:n())
op_powers %>% 
  slice_min(character, n = 5, with_ties = FALSE)
op_powers %>% 
  slice_min(character, prop = 0.5, with_ties = TRUE)
op_powers %>% 
  slice_tail(n = 5)
op_powers %>% 
  slice_tail(prop = 0.5)
op_powers %>% 
  slice_max(affiliations, n = 5, with_ties = FALSE)
op_powers %>% 
  slice_max(affiliations, prop = 0.5, with_ties = TRUE)
op_powers %>% 
  slice_head(n = 5)
op_powers %>% 
  slice_head(prop = 0.5)

2.5 Selecting

db03 <- op_powers %>%
  select(character, affiliations)
db03
db04 <- op_powers %>% 
  select(-level)
db04

2.6 Relocating

db05 <- op_powers %>% 
  relocate(character, power, affiliations)
db05

2.7 Renaming

status <- op_powers %>% 
  rename("status" = "level")
status

2.8 Counting

op_powers %>% 
  filter(affiliations == "Marine") %>% 
  count() %>% 
  kableExtra::kbl() %>% 
  kableExtra::kable_styling(bootstrap_options = "striped", 
                full_width = F, 
                position = "left")
n
10

2.9 Mutating

db06 <- op_powers %>% 
  mutate(anime = "One Piece",
         power_2 = power/2)

db06
db07 <- op_powers %>% 
  transmute(anime = "One Piece",
            power_2 = power/2)

db07

2.10 Grouping

db08 <- op_powers %>% 
  arrange(affiliations, desc(power)) %>% 
  group_by(affiliations) %>% 
  mutate(rank = row_number()) %>% 
  ungroup() %>% #close the group_by()
  arrange(affiliations) %>% 
  select(character, affiliations, rank)

db08

2.11 Summarising

db09 <- op_powers %>% 
  arrange(affiliations, desc(power)) %>% 
  group_by(affiliations) %>% 
  summarise(avg = mean(power, na.rm = TRUE),
            n = n()) %>%
  ungroup()

db09
db10a <- op_powers %>%
  mutate(fase1 = power*0.25,
         fase2 = power*0.75)

db10a
db10b <- db10a %>% 
  rowwise(character) %>%
  summarise(total = sum(fase1, fase2))
## `summarise()` has grouped output by 'character'. You can override using the `.groups` argument.
db10b

2.12 Dataset: Villain

villain_aff <- data.frame(
  character = c("Marshall D. Teach", "Charlotte Linlin", "Kaido", "Sakazuki Akainu", "Borsalino Kizaru"),
  affiliation = c("Blackbeard Pirates", "Big Mom Pirates", "Beasts Pirates", "Marine", "Marine")
)

character_power <- data.frame(
  name = c("Marshall D. Teach", "Kaido", "Sakazuki Akainu", "Monkey D. Dragon", "Silvers Rayleigh"),
  power = c(100, 100, 95, 99, 93)
)

2.13 Joining

#mutating joins
villain_aff %>% 
  left_join(character_power, by = c("character" = "name")) %>% 
  kableExtra::kbl() %>% 
  kableExtra::kable_styling(bootstrap_options = "striped", 
                full_width = F, 
                position = "left")
character affiliation power
Marshall D. Teach Blackbeard Pirates 100
Charlotte Linlin Big Mom Pirates NA
Kaido Beasts Pirates 100
Sakazuki Akainu Marine 95
Borsalino Kizaru Marine NA
#mutating joins
villain_aff %>% 
  right_join(character_power, by = c("character" = "name")) %>%
  kableExtra::kbl() %>% 
  kableExtra::kable_styling(bootstrap_options = "striped", 
                full_width = F, 
                position = "left")
character affiliation power
Marshall D. Teach Blackbeard Pirates 100
Kaido Beasts Pirates 100
Sakazuki Akainu Marine 95
Monkey D. Dragon NA 99
Silvers Rayleigh NA 93
#mutating joins
villain_aff %>% 
  inner_join(character_power, by = c("character" = "name"))  %>% 
  kableExtra::kbl() %>% 
  kableExtra::kable_styling(bootstrap_options = "striped", 
                full_width = F, 
                position = "left") 
character affiliation power
Marshall D. Teach Blackbeard Pirates 100
Kaido Beasts Pirates 100
Sakazuki Akainu Marine 95
#mutating joins
villain_aff %>% 
  full_join(character_power, by = c("character" = "name"))  %>% 
  kableExtra::kbl() %>% 
  kableExtra::kable_styling(bootstrap_options = "striped", 
                full_width = F, 
                position = "left")
character affiliation power
Marshall D. Teach Blackbeard Pirates 100
Charlotte Linlin Big Mom Pirates NA
Kaido Beasts Pirates 100
Sakazuki Akainu Marine 95
Borsalino Kizaru Marine NA
Monkey D. Dragon NA 99
Silvers Rayleigh NA 93
#filtering joins
villain_aff %>% 
  semi_join(character_power, by = c("character" = "name")) %>% 
  kableExtra::kbl() %>% 
  kableExtra::kable_styling(bootstrap_options = "striped", 
                full_width = F, 
                position = "left")
character affiliation
Marshall D. Teach Blackbeard Pirates
Kaido Beasts Pirates
Sakazuki Akainu Marine
#filtering joins
villain_aff %>% 
  anti_join(character_power, by = c("character" = "name")) %>% 
  kableExtra::kbl() %>% 
  kableExtra::kable_styling(bootstrap_options = "striped", 
                full_width = F, 
                position = "left")
character affiliation
Charlotte Linlin Big Mom Pirates
Borsalino Kizaru Marine

2.14 Conditional “ifelse”

db11 <- op_powers %>% 
  mutate(villain = ifelse(affiliations == "Blackbeard Pirates", "Villain", "NA"))

db11

2.15 Dataset: Luffy

luffy00 <- tribble(
  ~arc, ~power,
  "1-Punk Hazard", 75,
  "2-Dressrosa", NA,
  "3-Zou", 80,
  "4-Whole Cake Island", 82,
  "5-Levely", NA
)

kableExtra::kbl(luffy00) %>%
    kableExtra::kable_styling(bootstrap_options = "striped", 
                full_width = F, 
                position = "left")
arc power
1-Punk Hazard 75
2-Dressrosa NA
3-Zou 80
4-Whole Cake Island 82
5-Levely NA
luffy00 <- luffy00 %>% 
  add_row(arc = "6- Wano Country",
          power = 85)

kableExtra::kbl(luffy00) %>%
    kableExtra::kable_styling(bootstrap_options = "striped", 
                full_width = F, 
                position = "left")
arc power
1-Punk Hazard 75
2-Dressrosa NA
3-Zou 80
4-Whole Cake Island 82
5-Levely NA
6- Wano Country 85
is.na(luffy00)
##        arc power
## [1,] FALSE FALSE
## [2,] FALSE  TRUE
## [3,] FALSE FALSE
## [4,] FALSE FALSE
## [5,] FALSE  TRUE
## [6,] FALSE FALSE
#data frame
colSums(is.na(luffy00))
##   arc power 
##     0     2
mean(luffy00$power)
## [1] NA
mean(luffy00$power, na.rm = TRUE)
## [1] 80.5
#vector
which(is.na(luffy00))
## [1]  8 11
sum(is.na(luffy00)) 
## [1] 2

2.16 Treating “N/A”

luffy01 <- luffy00 %>%
  fill(power, .direction = "up") %>% 
  mutate(method = "fill")

kableExtra::kbl(luffy01) %>%
  kableExtra::kable_styling(bootstrap_options = "striped", 
                full_width = F, 
                position = "left")
arc power method
1-Punk Hazard 75 fill
2-Dressrosa 80 fill
3-Zou 80 fill
4-Whole Cake Island 82 fill
5-Levely 85 fill
6- Wano Country 85 fill
luffy02 <- luffy00 %>% 
  mutate(
    power = replace(power, is.na(power), mean(power, na.rm = TRUE)),
    method = "mean"
    )

#luffy02$power[is.na(luffy02$power)] <- mean(luffy02$power, na.rm = TRUE)
kableExtra::kbl(luffy02) %>%
  kableExtra::kable_styling(bootstrap_options = "striped", 
                full_width = F, 
                position = "left")
arc power method
1-Punk Hazard 75.0 mean
2-Dressrosa 80.5 mean
3-Zou 80.0 mean
4-Whole Cake Island 82.0 mean
5-Levely 80.5 mean
6- Wano Country 85.0 mean
luffy03 <- luffy00 %>% 
  mutate(power = zoo::na.approx(power),
         method = "interpolate")

kableExtra::kbl(luffy03) %>%
  kableExtra::kable_styling(bootstrap_options = "striped", 
                full_width = F, 
                position = "left")
arc power method
1-Punk Hazard 75.0 interpolate
2-Dressrosa 77.5 interpolate
3-Zou 80.0 interpolate
4-Whole Cake Island 82.0 interpolate
5-Levely 83.5 interpolate
6- Wano Country 85.0 interpolate
luffy00 %>% drop_na() %>% 
  kableExtra::kbl() %>% 
  kableExtra::kable_styling(bootstrap_options = "striped", 
                full_width = F, 
                position = "left")
arc power
1-Punk Hazard 75
3-Zou 80
4-Whole Cake Island 82
6- Wano Country 85

2.17 Binding

luffy04 <- rbind(luffy01, luffy02, luffy03)

luffy04 <- luffy01 %>% 
  bind_rows(luffy02, luffy03)


luffy04
luffy05 <- cbind(luffy01, luffy02, luffy03)

luffy05 <- luffy01 %>% 
  bind_cols(luffy02, luffy03)
## New names:
## * arc -> arc...1
## * power -> power...2
## * method -> method...3
## * arc -> arc...4
## * power -> power...5
## * ...
luffy05

2.18 Long-table

db01a <-  op_powers %>%
  left_join(op_ages, by = c("character" = "name")) %>% 
  select(-level) %>% 
  relocate(character, affiliations, power, age)
db01a
db01b <- db01a %>% 
  pivot_longer(cols = power:age, 
               names_to = "variable", 
               values_to = "value")
db01b

2.19 Wide-table

db01c <- db01b %>% 
  pivot_wider(names_from = variable,
              values_from = value)
db01c

2.20 Importing Table

writexl::write_xlsx(x = list(db01aSheet = db01a, db01bSheet = db01b, db01cSheet = db01c), path = "OnePiece.xlsx")

write.csv(db01a, file = "csv_db01a.csv")

3 Data Visualisation

3.1 Static Plot: No Faceting

plot01a <- op_powers %>%
  left_join(op_ages, by = c("character" = "name")) %>%
  relocate(character, age, power) %>%
  #group_by(level) %>%
  slice_max(power, n = 15, with_ties = FALSE) %>%
  #ungroup() %>%
  ggplot(aes(x = reorder(character, power),
             y = age)) +
  geom_point(aes(color = factor(affiliations), size = power)) +
  coord_cartesian(expand = TRUE, clip = "on") +
  coord_flip() +
  nord::scale_color_nord("aurora") +
  xlab("") +
  ylab("Age") +
  theme_test() +
  theme(
    axis.text.x = element_text(size = 8),
    axis.ticks.x = element_blank(),
    axis.line.x = element_blank(),
    axis.title.x = element_text(size = 7),
    axis.line.y = element_blank(),
    axis.title.y = element_text(size = 7),
    axis.text.y = element_text(size = 8),
    plot.title.position = "plot",
    plot.caption.position = "plot",
    legend.title = element_text(size = 7),
    legend.text = element_text(size = 7),
    legend.key.size = unit(0.5, "cm"),
    legend.spacing = unit(1, "cm"),
    plot.title = element_text(hjust = 0, size = 13, face = "bold"),
    plot.subtitle = element_text(hjust = 0, size = 12),
    plot.caption = element_text(hjust = 0, size = 12),
    # legend.title = element_blank(),
    legend.position = "right",
    strip.text.x = element_text(size = 8),
    panel.grid.major.y = element_line(colour = "grey97"),
    panel.ontop = FALSE,
    panel.spacing = unit(1, "lines")
  ) +
  guides(size = guide_legend("Power"), color = guide_legend("Affiliation")) +
  labs(title = "The top 15-most powerful characters",
       subtitle = "",
       caption = "") +
  scale_size_continuous(range = c(1, 5)) +
  scale_y_continuous(limits = c(10, 90),
                     breaks = c(20, 50, 80))
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.
plot01a

3.2 Static Plot: With Faceting

plot01b <- op_powers %>%
  left_join(op_ages, by = c("character" = "name")) %>%
  relocate(character, age, power) %>%
  #group_by(level) %>%
  slice_max(power, n = 15, with_ties = FALSE) %>%
  #ungroup() %>%
  ggplot(aes(x = reorder(character, power),
             y = age)) +
  geom_point(aes(color = factor(affiliations), size = power)) +
  coord_cartesian(expand = TRUE, clip = "on") +
  coord_flip() +
  nord::scale_color_nord("aurora") +
  xlab("") +
  ylab("Age") +
  theme_test() +
  theme(
    axis.text.x = element_text(size = 8),
    axis.ticks.x = element_blank(),
    axis.line.x = element_blank(),
    axis.title.x = element_text(size = 7),
    axis.line.y = element_blank(),
    axis.title.y = element_text(size = 7),
    axis.text.y = element_text(size = 8),
    plot.title.position = "plot",
    plot.caption.position = "plot",
    legend.title = element_text(size = 7),
    legend.text = element_text(size = 7),
    legend.key.size = unit(0.5, "cm"),
    legend.spacing = unit(1, "cm"),
    plot.title = element_text(hjust = 0, size = 13, face = "bold"),
    plot.subtitle = element_text(hjust = 0, size = 12),
    plot.caption = element_text(hjust = 0, size = 12),
    # legend.title = element_blank(),
    legend.position = "right",
    strip.text.x = element_text(size = 8),
    panel.grid.major.y = element_line(colour = "grey97"),
    panel.ontop = FALSE,
    panel.spacing = unit(1, "lines")
  ) +
  guides(size = guide_legend("Power"), color = guide_legend("Affiliation")) +
  labs(title = "The top 15-most powerful characters",
       subtitle = "",
       caption = "") +
  scale_size_continuous(range = c(1, 5)) +
  scale_y_continuous(limits = c(10, 90),
                     breaks = c(20, 50, 80)) +
  facet_grid(. ~ level)
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.
plot01b

3.3 Saving Image

ggsave(
  filename = "plot01a.png",
  #filename = "plot01a.pdf",
  plot = plot01a,
  #device = cairo_pdf,
  width = 297,
  height = 210,
  units = "mm"
)

3.4 Interactive Plot: No Faceting

plot02a <- op_powers %>%
  left_join(op_ages, by = c("character" = "name")) %>%
  relocate(character, age, power) %>%
  #group_by(level) %>%
  slice_max(power, n = 15, with_ties = FALSE) %>%
  #ungroup() %>%
  mutate(text = paste(
    "Character: ", reorder(character, power), 
    "\nAffiliation: ", factor(affiliations), 
    "\nAge: ", age, 
    "\nPower: ", power, 
    sep = "")) %>%
  ggplot(aes(x = reorder(character, power),
             y = factor(affiliations),
             text = text)) +
  geom_point(aes(color = age, size = power)) +
  coord_cartesian(expand = TRUE, clip = "on") +
  coord_flip() +
  #nord::scale_color_nord("victory_bonds", discrete = FALSE) +
  viridis::scale_colour_viridis(option = "viridis", direction = -1) +
  xlab("") +
  ylab("") +
  theme_test() +
  theme(
    axis.text.x = element_text(
      size = 8,
      angle = 90,
      vjust = 0.5,
      hjust = 1
    ),
    axis.ticks.x = element_blank(),
    axis.line.x = element_blank(),
    axis.title.x = element_text(size = 7),
    axis.line.y = element_blank(),
    axis.title.y = element_text(size = 7),
    axis.text.y = element_text(size = 8),
    plot.title.position = "plot",
    plot.caption.position = "plot",
    legend.title = element_text(size = 7),
    legend.text = element_text(size = 7),
    legend.key.size = unit(0.5, "cm"),
    legend.spacing = unit(1, "cm"),
    plot.title = element_text(hjust = 0, size = 13, face = "bold"),
    plot.subtitle = element_text(hjust = 0, size = 12),
    plot.caption = element_text(hjust = 0, size = 12),
    # legend.title = element_blank(),
    legend.position = "none",
    strip.text.x = element_text(size = 8),
    panel.grid.major.y = element_line(colour = "grey97"),
    panel.ontop = FALSE
  ) +
  guides(size = guide_legend("Power"), color = guide_colorbar("Age")) +
  labs(title = "",
       subtitle = "",
       caption = "") +
  scale_size_continuous(range = c(1, 5))
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.
ggplotly(plot02a, tooltip = "text")

Figure 3: The top 15-most powerful characters, without facet_grid(. ~ level)

3.5 Interactive Plot: With Faceting

plot02b <- op_powers %>% 
  left_join(op_ages, by = c("character" = "name")) %>% 
  relocate(character, age, power) %>% 
  #group_by(level) %>% 
  slice_max(power, n = 15, with_ties = FALSE) %>%
  #ungroup() %>% 
  mutate(text = paste(
    "Character: ", reorder(character, power), 
    "\nAffiliation: ", factor(affiliations), 
    "\nAge: ", age, 
    "\nPower: ", power, 
    sep = "")) %>%
  ggplot(aes(x = reorder(character, power), 
             y = factor(affiliations),
             text = text)) +
  geom_point(aes(color = age, size = power)) +
  coord_cartesian(expand = TRUE, clip = "on") +
  coord_flip() +
  #nord::scale_color_nord("victory_bonds", discrete = FALSE) +
  viridis::scale_colour_viridis(option = "viridis", direction = -1) +
  xlab("") +
  ylab("") +
  theme_test() +
  theme(
    axis.text.x = element_text(size = 8, angle = 90, vjust = 0.5, hjust=1),
    axis.ticks.x = element_blank(),
    axis.line.x = element_blank(),
    axis.title.x = element_text(size = 7),
    axis.line.y = element_blank(),
    axis.title.y = element_text(size = 7),
    axis.text.y = element_text(size = 8),
    plot.title.position = "plot",
    plot.caption.position = "plot",
    legend.title = element_text(size = 7),
    legend.text = element_text(size = 7),
    legend.key.size = unit(0.5, "cm"),
    legend.spacing = unit(1, "cm"),
    plot.title = element_text(
      hjust = 0, size = 13, face = "bold"
    ),
    plot.subtitle = element_text(hjust = 0, size = 12),
    plot.caption = element_text(hjust = 0, size = 12),
    # legend.title = element_blank(),
    legend.position = "none",
    strip.text.x = element_text(size = 8),
    panel.grid.major.y = element_line(colour = "grey97"),
    panel.ontop = FALSE,
    panel.spacing = unit(1, "lines")
  ) +
  guides(size = guide_legend("Power"), color = guide_colorbar("Age")) +
  labs(
    title = "",
    subtitle = "",
    caption = ""
  ) +
  scale_size_continuous(range = c(1,5)) +
  facet_grid(.~level)
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.
ggplotly(plot02b, tooltip = "text")

Figure 4: The top 15-most powerful characters, with facet_grid(. ~ level)


4 Clearing

#clearing the environment
ls()
##  [1] "character_power" "db01a"           "db01b"           "db01c"          
##  [5] "db03"            "db04"            "db05"            "db06"           
##  [9] "db07"            "db08"            "db09"            "db10a"          
## [13] "db10b"           "db11"            "law"             "luffy00"        
## [17] "luffy01"         "luffy02"         "luffy03"         "luffy04"        
## [21] "luffy05"         "op_ages"         "op_powers"       "plot01a"        
## [25] "plot01b"         "plot02a"         "plot02b"         "status"         
## [29] "villain_aff"
rm(list=ls())

5 Acknowledgements

5.1 References

5.2 Datasets

 

Contact me at ap.sulistiono@gmail.com